<%@ include file="/WEB-INF/includeFile.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <link rel="stylesheet" type="text/css" media="all" href="style.css">
  <link rel="stylesheet" type="text/css" media="all" href="fancybox/jquery.fancybox.css">
  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
  <script type="text/javascript" src="fancybox/jquery.fancybox.js?v=2.0.6"></script>
<title>Login Page</title>
</head>
<body>
<c:out value="${STATUS_MSG}"></c:out>
<form:form modelAttribute="loginTo" method="POST">
Login Here : Load Time : <c:out value="${executeTime}"></c:out>
<table>
<tr>
<td>Username</td>
<td>
	<form:input path="userName" />
</td>
</tr>
<tr>
<td>Password</td>
<td>
 <form:password path="passWord" />
</td>
</tr>
<tr>
	<td> <input type="submit" name="submit" value="Login" /></td>
	
</tr>
<tr>
	<td>
		<a class="modalbox" href="#inline">Register Here</a>
	</td>
	<td>
		<a href="/commonApp/forgotPassword.htm">Forgot Password?</a>
	</td>
</tr>
</table>

</form:form>
<!-- hidden inline form -->
<div id="inline" style="display: none;">
	<h2>Register to get Access</h2>

	<form id="contact" name="contact" action="#" method="post">
		<table>
			<tr>
				<td>First Name</td>
				<td><input type="text" id="fname" name="fname" class="txt"></td>
			</tr>
			<tr>
				<td>Last Name</td>
				<td><input type="text" id="lname" name="lname" class="txt"></td>
			</tr>
			<tr>
				<td><label for="email">Email</label></td>
				<td><input type="email" id="email" name="email" class="txt"></td>
			</tr>
		</table>
		<br>
		<button id="send">Send E-mail</button>
	</form>
</div>

<!-- basic fancybox setup -->
<script type="text/javascript">
	function validateEmail(email) { 
		var reg = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
		return reg.test(email);
	}

	$(document).ready(function() {
		$(".modalbox").fancybox();
		$("#contact").submit(function() { return false; });

		
		$("#send").on("click", function(){
			
				fname = document.getElementById("fname").value;
				lname = document.getElementById("lname").value;
				email = document.getElementById("email").value;
				
				$("#send").replaceWith("<em>Please wait...</em>");
				
				$.ajax({
					type: 'POST',
					url: 'createUser.htm',
					data: '&fname='+fname+'&lname='+lname+'&email='+email,
					success: function(data) {
						if(data != null) {
							$("#inline").fadeOut("fast", function(){
							    $(this).before("<p><strong>User successfully created, check your mail.</strong></p>");
							    setTimeout("$.fancybox.close()", 1000);
							});
						}
					}
				});
		});
	});
</script>

</body>
</html>